package com.banmoon.algorithm.leetcode;

public class Question504 {

    public static void main(String[] args) {
        System.out.println(convertToBase7(7));
    }

    public static String convertToBase7(int num) {
        if(num==0)
            return "0";
        StringBuilder result = new StringBuilder();
        int temp = Math.abs(num);
        while (temp>0){
            int mod = temp % 7;
            temp = temp/7;
            result.append(mod);
        }
        StringBuilder str = result.reverse();
        return num>0? str.toString(): "-"+str;
    }

}
